'- vg5000 bin2k7exec.sdlbas version 201308031532
finp$=command$(3):fout$=finp$+".k7":strt1=0x49FB:strt2=0x4A0A:exe1=strt1

open finp$ for input as #1
  lng1=lof(1):lng2=lng1+15:sum1=576
  for i=1 to lng1
    sum1=sum1+readbyte(1)
    next
  close #1

open finp$ for input as #1:open fout$ for output as #2

  for i=1 to 10:writebyte(2,0xD3):next

  writebyte(2,0x4D)
  for i=1 to 6
    if i<=len(finp$) then
      writebyte(2,asc(mid$(finp$,i,1)))
    else
      writebyte(2,0x00)
    end if
    next
  writebyte(2,0x00)

  writebyte(2,asc("1")):writebyte(2,asc("0"))
  for i=1 to 6:writebyte(2,0x00):next

  writebyte(2,strt1 mod 256)
  writebyte(2,(int(strt1/256))mod 256)
  writebyte(2,lng2 mod 256)
  writebyte(2,(int(lng2/256))mod 256)
  writebyte(2,sum1 mod 256)
  writebyte(2,(int(sum1/256))mod 256)

  for i=1 to 10:writebyte(2,0xD6):next

  writebyte(2,0x00):writebyte(2,0x08):writebyte(2,0x4A):writebyte(2,0x0A)
  writebyte(2,0x00):writebyte(2,0x9F):writebyte(2,0x31):writebyte(2,0x38)
  writebyte(2,0x39):writebyte(2,0x35):writebyte(2,0x34):writebyte(2,0x3A)
  writebyte(2,0x00):writebyte(2,0x00):writebyte(2,0x00)

  for i=1 to lng1:writebyte(2,readbyte(1)):next

  for i=1 to 10:writebyte(2,0x00):next
  close #1:close #2


